/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.escuela.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dsw2.escuela.modelo.Curso;

/**
 *
 * @author Maq-8
 */
@Stateless
public class CursoDao extends AbstractDao<Curso> implements CursoDaoLocal {
    @PersistenceContext(unitName = "Escuela-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CursoDao() {
        super(Curso.class);
    }

    @Override
    public boolean findByDuplicity(Curso grade) {
        Query q = em.createNamedQuery("Curso.findByDuplicity");
        q.setParameter("grupo", grade.getGrupo());
        q.setParameter("grado", grade.getGrado());
        return !q.getResultList().isEmpty();
    }
    
    
    
}
